//
//  ThirdPartyReadTableViewController.m
//  LearnDemo
//
//  Created by 龙 on 2018/5/21.
//  Copyright © 2018年 longlong. All rights reserved.
//
#define CellIdentifer @"UITableViewCell"

#import "ThirdPartyReadTableViewController.h"
#import "AFNetTableViewController.h"
#import "URLSessionTableViewController.h"
#import "SDViewController.h"

@interface ThirdPartyReadTableViewController ()
@property (nonatomic ,strong) NSArray<NSString *> *titleArray;
@end

@implementation ThirdPartyReadTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifer];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifer forIndexPath:indexPath];
    cell.textLabel.text = self.titleArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        AFNetTableViewController *tableVC = [[AFNetTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
        tableVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:tableVC animated:YES];
    }
    else if (indexPath.row == 1)
    {
        URLSessionTableViewController *tableVC = [[URLSessionTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
        tableVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:tableVC animated:YES];
    }
    else if (indexPath.row == 2)
    {
        SDViewController *tableVC = [[SDViewController alloc] init];
        tableVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:tableVC animated:YES];
    }
}


#pragma mark - setter and getter

- (NSArray<NSString *> *)titleArray
{
    if (_titleArray == nil)
    {
        _titleArray = @[@"AFNet相关",@"NSURLSession",@"SDWebImage"];
    }
    
    return _titleArray;
}

@end
